package com.southwind.springboottest.study.java中正则表达式;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @description：TODO
 * @author： HXG
 * @create： 2024/4/19 9:48
 */


public class Main2 {
    public static void main(String[] args) {
        String text = "The cat and the rat sat on the mat.";
        String pattern = "cat";
        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(text);
        while (m.find()) {
            System.out.println("Found: " + m.group() + " at index " + m.start());
        }
    }
}

